export default [
  {
    path: '/',
    // 重定向路由
    redirect: '/home',
    meta: {
      isHidden: false
    }
  },
  {
    path: '/home',
    component: () => import('@/pages/Home'),
    meta: {
      isHidden: false
    }
  },
  {
    path: '/login',
    component: () => import('@/pages/Login'),
    meta: {
      isHidden: true
    }
  },
  {
    path: '/register',
    component: () => import('@/pages/Register'),
    meta: {
      isHidden: true
    }
  },
  {
    path: '/search/:keyword?',
    component: () => import('@/pages/Search'),
    meta: {
      isHidden: false
    },
    name: 'search'
  },
  {
    path: '/detail/:skuId?',
    component: () => import('@/pages/Detail'),
    meta: {
      isHidden: false
    },
    name: 'detail'
  },
  {
    path: '/addcartsuccess',
    component: () => import('@/pages/AddCartSuccess'),
    meta: {
      isHidden: false
    },
    name: 'addcartsuccess'
  },
  {
    path: '/shopcart',
    component: () => import('@/pages/ShopCart'),
    meta: {
      isHidden: false
    },
    name: 'shopcart'
  },
  {
    path: '/trade',
    component: () => import('@/pages/Trade'),
    meta: {
      isHidden: false
    },
    name: 'trade',
    beforeEnter: (to, from, next) => {
      if (from.path == "/shopcart") {
        next();
      } else {
        // 中断当前导航。(浏览器URL发生改变，则URL会重置到from路由对应的地址)
        next(false);
      }
    }
  },
  {
    path: '/pay',
    component: () => import('@/pages/Pay'),
    meta: {
      isHidden: false
    },
    name: 'pay',
    beforeEnter: (to, from, next) => {
      if (from.path == "/trade") {
        next();
      } else {
        next(false);
      }
    }
  },
  {
    path: '/paysuccess',
    component: () => import('@/pages/PaySuccess'),
    meta: {
      isHidden: false
    },
    name: 'paysuccess'
  },
  {
    path: '/center',
    component: () => import('@/pages/Center'),
    meta: {
      isHidden: false
    },
    name: 'center',
    // 子路由
    children: [
      {
        path: 'myorder',
        component: () => import('@/pages/Center/myOrder')
      },
      {
        path: 'grouporder',
        component: () => import('@/pages/Center/groupOrder')
      },
      {
        path: '/center',
        redirect: '/center/myorder'
      }
    ]
  }
]